<?php
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
mb_language('uni');
$config = dirname(__FILE__);
$config = substr($config,0,strlen($config)-7);
include_once("{$config}config.php");
require DOCUMENTROOT . "/Smarty/libs/Smarty.class.php";
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
//模板设置
$smarty->template_dir	= realpath(DOCUMENTROOT . "/templates/");
$smarty->compile_dir	= realpath(DOCUMENTROOT . "/templates_c/");
$smarty->config_dir		= realpath(DOCUMENTROOT . "/configs/");
$smarty->cache_dir		= realpath(DOCUMENTROOT . "/cache/");
$smarty->assign("WEB_NAME",WEB_NAME);
$db = new WMysql(DB_HOST,DB_USER,DB_PWD,DB_NAME,DEBUG,WEB_CODE,0);
$db->select_db(DB_NAME);

if(isset($_POST))
	$_POST		= html_convert($_POST);
if(isset($_GET))
	$_GET		= html_convert($_GET);

function html_convert($array)
{
	if (is_array($array))
	{
		foreach($array as $key=>$value)
		{
			if(is_array($value))
				$array[$key]	= html_convert($value);
			else
				$array[$key]	= htm2text($value);
		}
	}
	else
		$array	= htm2text($array);
	return $array;
}
function htm2text($text="")
{
	$text = filter_xss($text,ALLOWED_HTMLTAGS);
	return str_replace(array('&', '<', '>', '"', "'"), array('&amp;', '&lt;', '&gt;', '&quot;', '&#039;'), $text);
}
?>